package com.example.cloudcommon.event.stream;

import lombok.Data;


@Data
public class EventStream {
    private String id;
    private String event;
    private Object data;
    private String comment;
    private Long retry;

    // 构造器
    public static EventStream of(Object data) {
        return new EventStream(null, "message", data, null, null);
    }

    public static EventStream of(String event, Object data) {
        return new EventStream(null, event, data, null, null);
    }

    public static EventStream of(String event, Object data, String comment) {
        return new EventStream(null, event, data, comment, null);
    }

    public static EventStream of(String event, Object data, String comment, Long retry) {
        return new EventStream(null, event, data, comment, retry);
    }

    public EventStream(String id, String event, Object data, String comment, Long retry) {
        this.id = id;
        this.event = event;
        this.data = data;
        this.comment = comment;
        if(retry == null){
            retry = 3L;
        }
        this.retry = retry;
    }
}
